<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>树人100-微信UI-1.0</title>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <!--<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">-->
    <link rel="stylesheet" href="__STATIC__/style/weui.min.css">
    <link rel="stylesheet" href="__STATIC__/style/cmgd.css">
    <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <!--奥森图标-->
    <link rel="stylesheet" href="__STATIC__/style/FontAwesome_4.2.0/css/font-awesome.min.css">
    <script type="text/javascript" src="__STATIC__/admin/js/layer/layer.js" ></script>
    <style>
        .fa-thumbs-up{color:#2fab87;}
    </style>
</head>
<body>

<div class="container" id="container">




    <!--顶部搜索-->
    <div class="page home js_show">

        <div class="page__bd" style="height: 100%;">

            <div class="weui-tab" id="navbar" >

                <div class="weui-cells weui-cells_form">
                    <div class="weui-cell">
                        <div class="weui-cell__bd">
                            <textarea class="weui-textarea" id="content" name="content" placeholder="请输入评论" rows="3"></textarea>
                            <div class="weui-textarea-counter"></div>
                        </div>
                    </div>
                </div>
                <div style="width:80%;margin:0 auto;padding: 10px 0 ;">
                    <input type="hidden" id="now" name="now" value="1" >
                    <input type="hidden" name="debate_id" id="debate_id" value="{$debate_id}">
                    <input type="hidden" name="debate_list_id" id="debate_list_id" value="{$debate_list_id}">
                    <input type="hidden" name="user_id" id="user_id" value="{$user_id}">
                    <a href="javascript:;" class="weui-btn weui-btn_primary" id="showTooltips">提交</a>
                </div>





                <div class="weui-tab__panel">
                    <div class="weui-panel articlelist">

                        <div class="weui-panel__bd" style="height: 100%;">
                            <article class="weui-article"> <h3>全部评论</h3></article>
                            <div id="pingluns">
                            </div>
                        </div>
                    </div>
                </div>

            </div>


        </div>
    </div>
</div>


</body>

<script type="text/javascript">

    AjaxPage();
    $(window).scroll(
            function() {
                var scrollTop = $(this).scrollTop();
                var scrollHeight = $(document).height();
                var windowHeight = $(this).height();
                if (scrollTop + windowHeight == scrollHeight) {
                    AjaxPage();
                }
            });

    function AjaxPage(){
        var now =  $('#now').val();
        var info_id = '{$debate_list_id}';
        if(now==''){
            now =1 ;
        }

        $.post('{:url("index/debate_comment_list")}',
                {id:info_id,page:now},
                function(data){
                    if(data.code==1) {

                        $html = '';
                        for(c in data.list){
                            //data.list[c].addtime



                            $html = $html + "<span  class='weui-media-box weui-media-box_appmsg'><div class='weui-media-box__hd'> <img class='weui-media-box__thumb' src='/uploads/face/"+data.list[c].head_img+"' alt=''></div><div class='weui-media-box__bd'><h5 class='weui-media-box__desc'>"+data.list[c].nickname+"</h5><p class='weui-media-box__desc commentlist'>"+data.list[c].comment+"</p><small class='weui-media-box__desc minTime'>"+data.list[c].addtime+"</small> </div></span>";
                        }

                        $("#pingluns").append($html);

                    }
                });
        next = parseInt(now)  + 1;
        $('#now').val(next) ;
    }

    //        顶部搜索
    $(function () {
        var $searchBar = $('#searchBar'),
                $searchResult = $('#searchResult'),
                $searchText = $('#searchText'),
                $searchInput = $('#searchInput'),
                $searchClear = $('#searchClear'),
                $searchCancel = $('#searchCancel');

        function hideSearchResult() {
            $searchResult.hide();
            $searchInput.val('');
        }

        function cancelSearch() {
            hideSearchResult();
            $searchBar.removeClass('weui-search-bar_focusing');
            $searchText.show();
        }

        $searchText.on('click', function () {
            $searchBar.addClass('weui-search-bar_focusing');
            $searchInput.focus();
        });
        $searchInput
                .on('blur', function () {
                    if (!this.value.length) cancelSearch();
                })
                .on('input', function () {
                    if (this.value.length) {
                        $searchResult.show();
                    } else {
                        $searchResult.hide();
                    }
                })
        ;
        $searchClear.on('click', function () {
            hideSearchResult();
            $searchInput.focus();
        });
        $searchCancel.on('click', function () {
            cancelSearch();
            $searchInput.blur();
        });

        $('#fabiao').on('click', function() {

            $('#navbar').hide();
            $('#navbar1').show();
        });

        $('#showTooltips').on('click', function(){
            var comment = $('#content').val();
            var user_id = $('#user_id').val();
            var id = $('#debate_list_id').val();

            //  alert(type+'|'+content);
             //alert(comment+'|'+user_id+'|'+id);
            $.post('{:url("index/debate_list_comment")}',
                    {id:id,user_id:user_id,comment:comment},
                    function(data){
                        console.log(data.code);
                        if(data.code==1) {

                            $html = "<span  class='weui-media-box weui-media-box_appmsg'><div class='weui-media-box__hd'> <img class='weui-media-box__thumb' src='"+data.list.img+"' alt=''></div><div class='weui-media-box__bd'><h5 class='weui-media-box__desc'>"+data.list.nickname+"</h5><p class='weui-media-box__desc commentlist'>"+data.list.comment+"</p><small class='weui-media-box__desc minTime'>"+data.list.addtime+"</small> </div></span>";
                            $("#pingluns").prepend($html);
                            $('#content').val('');
                            layer.msg('评论成功！',{icon:1,time:1500,shade: 0.1,});






                        }else{

                        }
                    });
        });



    });
    //顶部导航
    $(function () {
        $('.weui-navbar__item').on('click', function () {
            $(this).addClass('weui-bar__item_on').siblings('.weui-bar__item_on').removeClass('weui-bar__item_on');
        });
    });
    //底部导航
    $(function () {
        $('.weui-tabbar__item').on('click', function () {
            $(this).addClass('weui-bar__item_on').siblings('.weui-bar__item_on').removeClass('weui-bar__item_on');
        });
    });




</script>

</html>